package com.itheima;

import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/Demo1")
public class Demo1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//获取虚拟路径
        String contextPath = req.getContextPath();
        System.out.println(contextPath);
//获取映射路径
        String servletPath = req.getServletPath();
        System.out.println(servletPath);
//获取请求者ip地址(ipv6地址)
        String remoteAddr = req.getRemoteAddr();
        System.out.println(remoteAddr);
//获取请求的消息数据
        String queryString = req.getQueryString();
        System.out.println(queryString);
//获取统一资源标识符
        String requestURI = req.getRequestURI();
//获取统一资源定位符
        StringBuffer requestURL = req.getRequestURL();
        System.out.println(requestURI+requestURL);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
